home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2955 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: news.mel.aone.net.au!usenet
  2. From: clyde@hitech.com.au (Clyde Smith-Stubbs)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Floating point calculation order
  5. Date: Thu, 25 Jan 1996 06:27:55 GMT
  6. Organization: HI-TECH Software
  7. Message-ID: <310721ca.60354688@news.bne.aone.net.au>
  8. References: <m0tedv8-0002eqC@sice.nsk.su> <3104c6d9.134061184@nntp.ix.netcom.com> <DLnE5K.2xH@microunity.com> <mjs.822427333@hubcap>
  9. Reply-To: clyde@hitech.com.au
  10. NNTP-Posting-Host: skyhawk.hitech.com.au
  11. X-Newsreader: Forte Agent .99c/16.141
  12.  
  13. On 23 Jan 96 20:02:13 GMT, mjs@hubcap.clemson.edu (M. J. Saltzman)
  14. wrote:
  15.  
  16. >Would somebody explain under exactly what circumstances an ANSI
  17. >compiler is and is not allowed to reorder evaluation?  My recollection
  18.  
  19. Basically the compiler will honour operator precedence and
  20. associativity. The * and / are both left-associative and of
  21. equal precedence, so the * gets done first in a * b / c.
  22.  
  23. Of course there's always the "as-if" rule, meaning the compiler is
  24. actually free to generate whatever code it likes, as long as it
  25. behaves "as-if" it was executed according to the rules of the abstract
  26. machine defined by the standard. So it is quite alright for a compiler
  27. to reorder a * b * c since the result will be the same, but not a * b
  28. / c since the result will be different if the / is done first.
  29.  
  30. ----
  31.  Clyde Smith-Stubbs       | HI-TECH Software,       | Voice: +61 7 3300 5011
  32.  clyde@hitech.com.au      | P.O. Box 103, Alderley, | Fax:   +61 7 3300 5246
  33. http://www.hitech.com.au  | QLD, 4051, AUSTRALIA.   | BBS:   +61 7 3300 5235
  34. ----------------------------------------------------------------------------
  35. FREE! Download our shareware (FREE for noncommercial use) MS-DOS C Compiler!
  36.              Point your Web browser at http://www.hitech.com.au/
  37.